```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>三色标记算法 - 垃圾回收的核心机制</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e8efb 0%, #4a6cf7 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
        }
        .marker {
            position: relative;
            padding-left: 1.5rem;
        }
        .marker:before {
            content: "";
            position: absolute;
            left: 0;
            top: 0.5rem;
            width: 0.5rem;
            height: 0.5rem;
            border-radius: 50%;
        }
        .marker-white:before {
            background-color: #f8f9fa;
            border: 1px solid #dee2e6;
        }
        .marker-gray:before {
            background-color: #6c757d;
        }
        .marker-black:before {
            background-color: #212529;
        }
        .step-number {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 2rem;
            height: 2rem;
            background-color: #4a6cf7;
            color: white;
            border-radius: 50%;
            margin-right: 1rem;
            font-weight: bold;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <header class="hero-gradient text-white py-20 px-4">
        <div class="max-w-5xl mx-auto">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-2/3 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold mb-4 leading-tight">三色标记算法</h1>
                    <p class="text-xl mb-6 opacity-90">垃圾回收的核心机制与内存管理艺术</p>
                    <p class="text-lg opacity-80 mb-8">一种高效识别和回收垃圾对象的算法，通过三种颜色状态跟踪对象生命周期，确保内存管理的精确性与效率。</p>
                    <div class="flex items-center">
                        <a href="#overview" class="bg-white text-blue-600 hover:bg-blue-50 px-6 py-3 rounded-lg font-medium transition duration-300 mr-4">
                            算法概述 <i class="fas fa-arrow-right ml-2"></i>
                        </a>
                        <a href="#visualization" class="text-white hover:text-blue-100 px-6 py-3 rounded-lg font-medium border border-white hover:border-blue-100 transition duration-300">
                            可视化展示 <i class="fas fa-chart-pie ml-2"></i>
                        </a>
                    </div>
                </div>
                <div class="md:w-1/3 flex justify-center">
                    <div class="relative w-64 h-64">
                        <div class="absolute inset-0 bg-white bg-opacity-20 rounded-full"></div>
                        <div class="absolute top-0 left-1/2 transform -translate-x-1/2 w-16 h-16 bg-white rounded-full flex items-center justify-center shadow-lg">
                            <span class="text-blue-600 text-2xl font-bold">白</span>
                        </div>
                        <div class="absolute bottom-0 left-0 w-16 h-16 bg-gray-600 rounded-full flex items-center justify-center shadow-lg">
                            <span class="text-white text-2xl font-bold">灰</span>
                        </div>
                        <div class="absolute bottom-0 right-0 w-16 h-16 bg-black rounded-full flex items-center justify-center shadow-lg">
                            <span class="text-white text-2xl font-bold">黑</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </header>

    <!-- Main Content -->
    <main class="max-w-5xl mx-auto px-4 py-12">
        <!-- Overview Section -->
        <section id="overview" class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-1 bg-blue-500 mr-4"></div>
                <h2 class="text-3xl font-bold">算法概述</h2>
            </div>
            <p class="text-lg text-gray-700 mb-6">三色标记算法（Three-Color Marking Algorithm）是现代垃圾回收系统中的核心机制，作为标记-清除（Mark-and-Sweep）算法的变体，它通过三种颜色状态高效追踪对象生命周期，精确识别和回收内存中的垃圾对象。</p>
            
            <div class="grid md:grid-cols-3 gap-6 mb-12">
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 rounded-full bg-white border-2 border-gray-300 flex items-center justify-center mr-3">
                            <span class="text-gray-600">白</span>
                        </div>
                        <h3 class="text-xl font-semibold">白色对象</h3>
                    </div>
                    <p class="text-gray-600">表示对象尚未被标记，可能为垃圾对象。在垃圾回收完成后，所有白色对象将被系统回收释放内存空间。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 rounded-full bg-gray-600 flex items-center justify-center mr-3">
                            <span class="text-white">灰</span>
                        </div>
                        <h3 class="text-xl font-semibold">灰色对象</h3>
                    </div>
                    <p class="text-gray-600">表示对象已被标记，但其引用对象尚未完成标记。灰色对象处于处理队列中，等待进一步扫描其引用关系。</p>
                </div>
                <div class="bg-white p-6 rounded-xl shadow-md card-hover">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 rounded-full bg-black flex items-center justify-center mr-3">
                            <span class="text-white">黑</span>
                        </div>
                        <h3 class="text-xl font-semibold">黑色对象</h3>
                    </div>
                    <p class="text-gray-600">表示对象及其所有引用对象均已完成标记，确认为存活对象。黑色对象将不会被回收，直到下次垃圾回收周期。</p>
                </div>
            </div>
        </section>

        <!-- Workflow Section -->
        <section id="workflow" class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-1 bg-blue-500 mr-4"></div>
                <h2 class="text-3xl font-bold">工作流程</h2>
            </div>
            
            <div class="space-y-8">
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <div class="flex items-start">
                        <span class="step-number">1</span>
                        <div>
                            <h3 class="text-xl font-semibold mb-3">初始标记阶段</h3>
                            <p class="text-gray-700">从根对象（GC Root）开始扫描，包括栈引用、静态字段等，将所有直接可达对象标记为灰色。此阶段通常需要暂停应用程序执行（Stop-The-World）。</p>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <div class="flex items-start">
                        <span class="step-number">2</span>
                        <div>
                            <h3 class="text-xl font-semibold mb-3">标记传播阶段</h3>
                            <p class="text-gray-700">遍历灰色对象队列，将每个灰色对象的所有引用对象标记为灰色，同时将当前对象标记为黑色。新发现的灰色对象加入处理队列，此阶段可并发执行。</p>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <div class="flex items-start">
                        <span class="step-number">3</span>
                        <div>
                            <h3 class="text-xl font-semibold mb-3">标记完成阶段</h3>
                            <p class="text-gray-700">当灰色对象队列为空时，表示所有可达对象已完成标记。剩余白色对象确认为垃圾对象，准备进入清除阶段。</p>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <div class="flex items-start">
                        <span class="step-number">4</span>
                        <div>
                            <h3 class="text-xl font-semibold mb-3">清除阶段</h3>
                            <p class="text-gray-700">回收所有白色对象占用的内存空间，将其返还给堆内存管理器。此阶段可与应用程序并发执行，减少停顿时间。</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Visualization Section -->
        <section id="visualization" class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-1 bg-blue-500 mr-4"></div>
                <h2 class="text-3xl font-bold">算法可视化</h2>
            </div>
            
            <div class="bg-white p-6 rounded-xl shadow-md mb-8">
                <h3 class="text-xl font-semibold mb-4">三色标记算法状态转换图</h3>
                <div class="mermaid">
                    stateDiagram-v2
                        [*] --> White
                        White --> Gray : 从根可达
                        Gray --> Black : 扫描完成
                        Black --> White : 下次GC周期
                        Gray --> White : 并发修改导致丢失
                </div>
            </div>
            
            <div class="bg-white p-6 rounded-xl shadow-md">
                <h3 class="text-xl font-semibold mb-4">垃圾回收过程模拟</h3>
                <div class="mermaid">
                    graph TD
                        %% 根对象
                        Root[GC Roots] --> A
                        Root --> B
                        
                        %% 第一层对象
                        A --> C
                        A --> D
                        B --> E
                        B --> F
                        
                        %% 第二层对象
                        C --> G
                        D --> H
                        E --> I
                        F --> J
                        
                        %% 初始状态全部为白色
                        classDef white fill:#f8f9fa,stroke:#dee2e6,stroke-width:2px
                        class A,B,C,D,E,F,G,H,I,J white
                        
                        %% 标记过程
                        classDef gray fill:#6c757d,stroke:#495057,stroke-width:2px,color:white
                        classDef black fill:#212529,stroke:#000,stroke-width:2px,color:white
                        
                        %% 模拟标记顺序
                        linkStyle 0,1 stroke:#4a6cf7,stroke-width:3px
                        class A,B gray
                </div>
                <div class="mt-4 flex justify-center space-x-4">
                    <button id="step1" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition">初始标记</button>
                    <button id="step2" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition">标记传播</button>
                    <button id="step3" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition">标记完成</button>
                    <button id="step4" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 transition">清除阶段</button>
                </div>
            </div>
        </section>

        <!-- Pros & Cons Section -->
        <section id="pros-cons" class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-12 h-1 bg-blue-500 mr-4"></div>
                <h2 class="text-3xl font-bold">优势与挑战</h2>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <div class="flex items-center mb-4">
                        <i class="fas fa-check-circle text-green-500 text-2xl mr-3"></i>
                        <h3 class="text-xl font-semibold">算法优势</h3>
                    </div>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span><strong>精确标记：</strong>通过灰色对象队列确保所有可达对象都被正确标记，避免误回收存活对象</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span><strong>并发支持：</strong>标记传播阶段可实现并发执行，减少应用程序停顿时间</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span><strong>增量回收：</strong>支持增量式垃圾回收，分阶段完成标记过程</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                            <span><strong>内存效率：</strong>只保留真正活跃对象，有效回收内存碎片</span>
                        </li>
                    </ul>
                </div>
                
                <div class="bg-white p-6 rounded-xl shadow-md">
                    <div class="flex items-center mb-4">
                        <i class="fas fa-exclamation-triangle text-yellow-500 text-2xl mr-3"></i>
                        <h3 class="text-xl font-semibold">面临挑战</h3>
                    </div>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span><strong>暂停时间：</strong>初始标记阶段需要暂停应用程序，对实时系统有影响</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span><strong>CPU开销：</strong>全堆扫描可能消耗大量CPU资源</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span><strong>并发问题：</strong>应用程序并发修改对象图可能导致标记遗漏</span>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-times text-red-500 mt-1 mr-2"></i>
                            <span><strong>内存占用：</strong>需要额外空间维护标记位和灰色队列</span>
                        </li>
                    </ul>
                </div>
            </div>
        </section>

        <!-- Applications Section -->
        <section id="applications">
            <div class="flex items-center mb-8">
                <div class="w-12 h-1 bg-blue-500 mr-4"></div>
                <h2 class="text-3xl font-bold">实际应用</h2>
            </div>
            
            <div class="bg-white p-6 rounded-xl shadow-md">
                <p class="text-gray-700 mb-6">三色标记算法是现代垃圾回收系统的理论基础，其核心思想被多种高级垃圾回收器采用和扩展：</p>
                
                <div class="grid md:grid-cols-2 gap-6">
                    <div class="border-l-4 border-blue-500 pl-4">
                        <h4 class="text-lg font-semibold mb-2">CMS 收集器</h4>
                        <p class="text-gray-600">Concurrent Mark-Sweep 收集器使用三色标记算法实现并发标记，减少老年代回收的停顿时间。</p>
                    </div>
                    <div class="border-l-4 border-blue-500 pl-4">
                        <h4 class="text-lg font-semibold mb-2">G1 收集器</h4>
                        <p class="text-gray-600">Garbage-First 收集器基于三色标记实现分区域回收，平衡吞吐量和停顿时间。</p>
                    </div>
                    <div class="border-l-4 border-blue-500 pl-4">
                        <h4 class="text-lg font-semibold mb-2">ZGC 收集器</h4>
                        <p class="text-gray-600">Z Garbage Collector 利用三色标记实现亚毫秒级停顿，适合大内存应用。</p>
                    </div>
                    <div class="border-l-4 border-blue-500 pl-4">
                        <h4 class="text-lg font-semibold mb-2">Shenandoah</h4>
                        <p class="text-gray-600">低延迟垃圾收集器通过三色标记实现并发压缩，减少内存碎片。</p>
                    </div>
                </div>
                
                <div class="mt-8 bg-blue-50 p-4 rounded-lg border border-blue-200">
                    <div class="flex">
                        <i class="fas fa-lightbulb text-blue-500 text-2xl mr-3 mt-1"></i>
                        <div>
                            <h4 class="text-lg font-semibold text-blue-700 mb-2">算法演进</h4>
                            <p class="text-blue-600">现代垃圾回收器通过引入写屏障、增量标记、并发标记等技术优化三色标记算法，在保持准确性的同时提高性能。例如，G1收集器使用SATB（Snapshot-At-The-Beginning）写屏障解决并发修改问题。</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-8">
        <div class="max-w-5xl mx-auto px-4">
            <div class="flex flex-col md:flex-row justify-between items-center">
                <div class="mb-4 md:mb-0">
                    <h3 class="text-xl font-semibold text-white mb-2">技术小馆</h3>
                    <p class="text-gray-400">探索计算机科学的奥秘</p>
                </div>
                <div>
                    <a href="http://www.yuque.com/jtostring" class="text-blue-400 hover:text-blue-300 transition duration-300 flex items-center">
                        <i class="fas fa-globe mr-2"></i> http://www.yuque.com/jtostring
                    </a>
                </div>
            </div>
            <div class="border-t border-gray-800 mt-8 pt-8 text-center text-gray-500 text-sm">
                &copy; 2023 技术小馆 版权所有
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        // 简单的交互逻辑
        document.getElementById('step1').addEventListener('click', function() {
            alert('模拟初始标记阶段：从GC Roots出发，标记直接可达对象为灰色');
        });
        
        document.getElementById('step2').addEventListener('click', function() {
            alert('模拟标记传播阶段：处理灰色对象，标记其引用对象为灰色，自身变为黑色');
        });
        
        document.getElementById('step3').addEventListener('click', function() {
            alert('模拟标记完成阶段：所有灰色对象处理完毕，剩余白色对象确认为垃圾');
        });
        
        document.getElementById('step4').addEventListener('click', function() {
            alert('模拟清除阶段：回收所有白色对象占用的内存空间');
        });
    </script>
</body>
</html>
```